package com.etheart.model.entity;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.DateBridge;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.IndexedEmbedded;
import org.hibernate.search.annotations.Resolution;
import org.hibernate.search.annotations.Similarity;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TokenizerDef;
import org.wltea.analyzer.lucene.IKSimilarity;
import org.wltea.analyzer.solr.IKTokenizerFactory;

import com.etheart.framework.core.fulltextsearch.Highlight;

/**
 * Song entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "_song", catalog = "etheart")
@Indexed
@AnalyzerDef(name = "customanalyzer_song",
		tokenizer = @TokenizerDef(factory = IKTokenizerFactory.class))
@Similarity(impl=IKSimilarity.class)
public class Song implements java.io.Serializable {

	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	@DocumentId
	@Field(index = Index.UN_TOKENIZED, store = Store.NO)
	private Long id;
	
	@IndexedEmbedded(prefix="album.",depth=1)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "albumid")
	private Album album;
	
	
	@IndexedEmbedded(prefix="singer.",depth=1)
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "singerid")
	private Singer singer ;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column(name = "songname", length = 255)
	@Highlight
	private String songname;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column(name = "_language", length = 20)
	private String language;
	
	@Column(name = "net_id", length = 30)
	private String netId;
	
	@Column(name="play_count")
	private Integer playCount;
	
	@Column(name="fav_count")
	private Integer favCount;
	
	@Column(name="play_complete_count")
	private Integer playCompleteCount;
	
	@Column(name="comm_count")
	private Integer commCount;
	
	@Column(name = "add_time", length = 19)
	@DateBridge(resolution = Resolution.DAY)
	private Date addTime;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column(name = "_type", length = 20)
	private String type;
	
	@Column(name = "from_url", length =255)
	private String fromUrl;
	
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Column(name = "style", length = 100)
	private String style;

	@Column(name="lrc_url")
	private String lrcUrl;
	
	@Column(name="lrc_content")
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Highlight(showFull=false)
	private String lrcContent;
	
	@Column(name="singername")
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Highlight
	private String singername;

	
	@Column(name="albumname")
	@Field(index = Index.TOKENIZED, store = Store.NO)
	@Highlight
	private String albumname;

	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "song")
	private Set<Resource> resources = new HashSet<Resource>(0);
	
	/** default constructor */
	public Song() {
	}

	

	// Property accessors
	
	public Long getId() {
		return this.id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	public String getNetId() {
		return netId;
	}

	public void setNetId(String netId) {
		this.netId = netId;
	}
	
	public Album getAlbum() {
		return this.album;
	}

	public void setAlbum(Album album) {
		this.album = album;
	}


	public String getSongname() {
		return songname;
	}



	public void setSongname(String songname) {
		this.songname = songname;
	}



	public String getFromUrl() {
		return fromUrl;
	}

	public void setFromUrl(String fromUrl) {
		this.fromUrl = fromUrl;
	}


	public String getLanguage() {
		return this.language;
	}

	public void setLanguage(String language) {
		this.language = language;
	}



	public Singer getSinger() {
		return singer;
	}



	public void setSinger(Singer singer) {
		this.singer = singer;
	}



	public Integer getPlayCount() {
		return playCount;
	}



	public void setPlayCount(Integer playCount) {
		this.playCount = playCount;
	}



	public Integer getFavCount() {
		return favCount;
	}



	public void setFavCount(Integer favCount) {
		this.favCount = favCount;
	}



	public Integer getPlayCompleteCount() {
		return playCompleteCount;
	}



	public void setPlayCompleteCount(Integer playCompleteCount) {
		this.playCompleteCount = playCompleteCount;
	}



	public Integer getCommCount() {
		return commCount;
	}



	public void setCommCount(Integer commCount) {
		this.commCount = commCount;
	}



	public Date getAddTime() {
		return addTime;
	}



	public void setAddTime(Date addTime) {
		this.addTime = addTime;
	}



	public String getType() {
		return type;
	}



	public void setType(String type) {
		this.type = type;
	}



	public String getStyle() {
		return style;
	}



	public void setStyle(String style) {
		this.style = style;
	}
	
	public String getLrcUrl() {
		return lrcUrl;
	}



	public void setLrcUrl(String lrcUrl) {
		this.lrcUrl = lrcUrl;
	}



	public String getLrcContent() {
		return lrcContent;
	}



	public void setLrcContent(String lrcContent) {
		this.lrcContent = lrcContent;
	}



	public String getSingername() {
		return singername;
	}



	public void setSingername(String singername) {
		this.singername = singername;
	}



	public String getAlbumname() {
		return albumname;
	}



	public void setAlbumname(String albumname) {
		this.albumname = albumname;
	}



	public Set<Resource> getResources() {
		return resources;
	}



	public void setResources(Set<Resource> resources) {
		this.resources = resources;
	}

}